package org.softmed.ATComm.server;

import org.restlet.Application;
import org.restlet.Context;
import org.restlet.Restlet;
import org.restlet.Router;
import org.restlet.util.RouteList;
import org.softmed.ATComm.ATControlFacade;

public class ATCommApplication extends Application {

	private Router router;
	private ATControlFacade atControl;

	public ATCommApplication(Context parentContext, ATControlFacade atControl) {
		super(parentContext);
		this.atControl = atControl;
	}

	/**
	 * Creates a root Restlet that will receive all incoming calls.
	 */
	@Override
	public synchronized Restlet createRoot() {
		router = new Router(getContext());

		router.attach("/serialports", new SerialPortListerRestlet(atControl));
		router.attach("/serialport", new SerialPortRestlet(atControl));
		router.attach("/sms", new SMSRestlet(atControl));

		return router;
	}

	public Router getRouter() {
		return router;
	}

}
